/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package ms.jasim.model.items.impl;

import ms.jasim.model.impl.ModelObjectImpl;
import ms.jasim.model.items.Item;
import ms.jasim.model.items.ItemsPackage;
import ms.jasim.model.items.ObjectProperty;
import ms.jasim.model.items.PropertyDescriptor;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Object Property</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.jasim.model.items.impl.ObjectPropertyImpl#getDescriptorID <em>Descriptor ID</em>}</li>
 *   <li>{@link ms.jasim.model.items.impl.ObjectPropertyImpl#getDescriptor <em>Descriptor</em>}</li>
 *   <li>{@link ms.jasim.model.items.impl.ObjectPropertyImpl#getItem <em>Item</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ObjectPropertyImpl extends ModelObjectImpl implements ObjectProperty {
	/**
	 * The default value of the '{@link #getDescriptorID() <em>Descriptor ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescriptorID()
	 * @generated
	 * @ordered
	 */
	protected static final String DESCRIPTOR_ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDescriptorID() <em>Descriptor ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescriptorID()
	 * @generated
	 * @ordered
	 */
	protected String descriptorID = DESCRIPTOR_ID_EDEFAULT;

	/**
	 * The cached value of the '{@link #getDescriptor() <em>Descriptor</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescriptor()
	 * @generated
	 * @ordered
	 */
	protected PropertyDescriptor descriptor;

	/**
	 * The cached value of the '{@link #getItem() <em>Item</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItem()
	 * @generated
	 * @ordered
	 */
	protected Item item;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ObjectPropertyImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ItemsPackage.Literals.OBJECT_PROPERTY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDescriptorID() {
		return descriptorID;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescriptorID(String newDescriptorID) {
		String oldDescriptorID = descriptorID;
		descriptorID = newDescriptorID;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR_ID, oldDescriptorID, descriptorID));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PropertyDescriptor getDescriptor() {
		if (descriptor != null && descriptor.eIsProxy()) {
			InternalEObject oldDescriptor = (InternalEObject)descriptor;
			descriptor = (PropertyDescriptor)eResolveProxy(oldDescriptor);
			if (descriptor != oldDescriptor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR, oldDescriptor, descriptor));
			}
		}
		return descriptor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PropertyDescriptor basicGetDescriptor() {
		return descriptor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescriptor(PropertyDescriptor newDescriptor) {
		PropertyDescriptor oldDescriptor = descriptor;
		descriptor = newDescriptor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR, oldDescriptor, descriptor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Item getItem() {
		return item;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetItem(Item newItem, NotificationChain msgs) {
		Item oldItem = item;
		item = newItem;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ItemsPackage.OBJECT_PROPERTY__ITEM, oldItem, newItem);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setItem(Item newItem) {
		if (newItem != item) {
			NotificationChain msgs = null;
			if (item != null)
				msgs = ((InternalEObject)item).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ItemsPackage.OBJECT_PROPERTY__ITEM, null, msgs);
			if (newItem != null)
				msgs = ((InternalEObject)newItem).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ItemsPackage.OBJECT_PROPERTY__ITEM, null, msgs);
			msgs = basicSetItem(newItem, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ItemsPackage.OBJECT_PROPERTY__ITEM, newItem, newItem));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ItemsPackage.OBJECT_PROPERTY__ITEM:
				return basicSetItem(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR_ID:
				return getDescriptorID();
			case ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR:
				if (resolve) return getDescriptor();
				return basicGetDescriptor();
			case ItemsPackage.OBJECT_PROPERTY__ITEM:
				return getItem();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR_ID:
				setDescriptorID((String)newValue);
				return;
			case ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR:
				setDescriptor((PropertyDescriptor)newValue);
				return;
			case ItemsPackage.OBJECT_PROPERTY__ITEM:
				setItem((Item)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR_ID:
				setDescriptorID(DESCRIPTOR_ID_EDEFAULT);
				return;
			case ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR:
				setDescriptor((PropertyDescriptor)null);
				return;
			case ItemsPackage.OBJECT_PROPERTY__ITEM:
				setItem((Item)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR_ID:
				return DESCRIPTOR_ID_EDEFAULT == null ? descriptorID != null : !DESCRIPTOR_ID_EDEFAULT.equals(descriptorID);
			case ItemsPackage.OBJECT_PROPERTY__DESCRIPTOR:
				return descriptor != null;
			case ItemsPackage.OBJECT_PROPERTY__ITEM:
				return item != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (descriptorID: ");
		result.append(descriptorID);
		result.append(')');
		return result.toString();
	}

	
	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setName(String value) {
		// TODO Auto-generated method stub
	}

	@Override
	public boolean isReservedName() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void setReservedName(boolean value) {
		// TODO Auto-generated method stub
		
	}

} //ObjectPropertyImpl
